<?php
namespace app\msgapi\controller;

use app\msgapi\service\HuihuaMsgService;
use app\msgapi\service\HuihuaSensitiveService;
use app\Request;

//订阅管理控制器
class Hssubscribe extends Base
{
    public function __construct(HuihuaSensitiveService $service)
    {
        parent::__construct($service);
        $this->service = $service;
    }

    /**订阅列表
     * @param Request $request
     * @return array|\think\response\Json
     * @throws \think\db\exception\DbException
     */
    public function index(Request $request)
    {
        $data = $request->only(['keyword','type','page','limit','receive_user'],'post');
        return $this->service->getLists($data,$request->admin_groupid,$request->adminid);
    }

    /**新增保存\更新保存
     * @param Request $request
     * @return \think\response\Json
     */
    public function save(Request $request)
    {
        $data = $request->only(['id','type','attr','userlist','admin_template','send_template','adt_state','set_state','state','receive_user'],'post');
        return $this->service->_save($data,$request->admin_groupid,$request->adminid);
    }

    /**快捷状态调整
     * @param Request $request
     * @return \think\response\Json
     */
    public function setStatus(Request $request)
    {
        $data = $request->only(['id','state','sort','receive_user'],'post');
        return $this->service->setStatus($data,$request->admin_groupid,$request->adminid);
    }

    /**预警统计列表
     * @param Request $request
     * @return \think\response\Json
     */
    public function getSubscribeList(Request $request)
    {
        $data = $request->only(['page','limit','year','receive_user'],'post');
       return $this->service->getSubscribeList($data,$request->admin_groupid,$request->adminid);
    }

    /**预警统计查看
     * @param Request $request
     * @return \think\response\Json
     */
    public function getSenList(Request $request)
    {
        $data = $request->only(['page','limit','weektime','receive_user'],'post');
        return $this->service->getSenList($data,$request->admin_groupid,$request->adminid);
    }

    //查看上下文
    public function getContext(Request $request)
    {
        $data = $request->only(['limit','msgid','group_id'],'post');
        $huihuaMsgService = new HuihuaMsgService();
        return $huihuaMsgService->getChatContext($data,$request->admin_groupid,$request->adminid);
    }

    public function test(){
       return $this->service->sendLongTimeNoReplyReminder();
    }
}